<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script>
        //要求：将数组[2,0,6,1,77,0,52,0,25,7]中大于等于10的元素筛选出来，放入新数组
        //1.声明一个新的数组存放新数据newArr
        //2.遍历原来的旧数组，找出大于等于10的元素
        //3.依次追加给新组newArr
        // 方法1
        var arr = [2, 0, 6, 1, 77, 0, 52, 0, 25, 7];
        var newArr = [];
        var j = 0;
        for (var i = 0; i < arr.length; i++) {
            if (arr[i] >= 10) {
                newArr [j] = arr[i];
                j++;
            }
        }
        console.log(newArr);
        // 方法二
        var arr = [2, 0, 6, 1, 77, 0, 52, 0, 25, 7];
        var newArr = [];//空数组 其长度newArr.length刚开始是0
        for (var i = 0; i < arr.length; i++) {
            if (arr[i] >= 10) {
                newArr[newArr.length] = arr[i];
            }
        }
        console.log(newArr);
    </script>
</head>
<body>
    
</body>
</html>